#include <iostream>
#include <algorithm>
#include "Finder.h"
#include "Song.h"
#include "Album.h"
#include "MusicCollection.h"

bool Finder::findstr(std::string const& search) const {
	//string function that checks if search string
	//is part of media name
	return search.find(mSearch) != std::string::npos;
}

TMedia const * Finder::getMedia() const {
	return &mFoundMedia;
}

void Finder::Visit(Song * song){
	if (findstr(*song->getName())){
		//add a found Song
		mFoundMedia.push_back(song);
	}
}

void Finder::Visit(Album * album){
	if (findstr(*album->getName())){
		//add a found Album
		mFoundMedia.push_back(album);
	}
}

void Finder::Visit(MusicCollection * collection){
	if (findstr(*collection->getName())){
		//add a found MusicCollection
		mFoundMedia.push_back(collection);
	}
}